
''' (Program designed by) '''
# Jesse Mcgirr, John Connelly, Lucas Miller

''' (Program title) '''
# Zombie Apocalypse Simulation Generator

''' (Program length) '''
# Whitespace: 195 lines
# Comments:   158 lines
# Code:       1007 lines
#--------------------------------
# Total:      1360 lines

#----------------------------------------------------#
'''            (Main Screen Turn On)               '''
#----------------------------------------------------#

#external file containing class, "Human"
from Human import Human

#external file containing class, "Zombie"
from Zombie import Zombie

#external file containing class, "Building"
from Building import Building

#external file containing basic functions that we will need
from base_functions import *

from Tkinter import *
from pygame import mixer
from time import sleep
from os import getcwd 

def menu_keys(event,root,canvas):
	#We only really care about the space and enter keys - in the future, this would also listen for the arrow keys for menu interaction
	if event.keysym == 'space' or event.keysym == 'Return':
		#cool! they pressed space (or Enter) - signal the "groan" sound and transition
		mixer.Sound("groan.wav").play()
		
		#gonna fade out... sort of.
		fade_image = PhotoImage(file="fade25.gif")
		canvas.tag_raise(canvas.create_image((300,200),image=fade_image))
		root.update()
		sleep(.01)
		
		fade_image = PhotoImage(file="fade50.gif")
		canvas.tag_raise(canvas.create_image((300,200),image=fade_image))
		root.update()
		sleep(.01)
		
		fade_image = PhotoImage(file="fade75.gif")
		canvas.tag_raise(canvas.create_image((300,200),image=fade_image))
		root.update()
		sleep(.01)
		
		#we will now remove our 'game over' canvas and re-initialize the game
		canvas.pack_forget()
		canvas.destroy()
		canvas = Canvas(root, width=600, height=400, background="#000")
		canvas.pack(side='top')
		root.update()
		sleep(.1)
		canvas.pack_forget()
		canvas.destroy()
		initialize_window(root)
def main():

	#main function - call our initialization functions
	
	#make a Tkinter instance
	root = Tk()
	
	try:
		#attempt to set the title and icon for this window
		root.wm_title("Zombie Apocalypse Simulation Generator")
		root.wm_iconbitmap('icon.ico')
		
	except:
		try:
			#one last attempt to set an icon
			root.iconbitmap('icon.ico')
		except:
			try:
				root.iconbitmap('@'+getcwd()+'\icon.ico')
			except:
				try:
					root.iconbitmap('@'+getcwd()+'\icon.xpm')
				except:
					#don't really need to catch this - we just won't have an icon
					print "(Icon Error: continuing happily!)"
		#also set the title of the window (using an alternate call)
		root.title("Zombie Apocalypse Simulation Generator")
	
	#make an intro screen
	canvas = Canvas(root, width=600, height=400, background="#000")
	canvas.pack(side='top')
	title_image = PhotoImage(file="title_screen_sm.gif")
	canvas.create_image((300,200),image=title_image)
	canvas.create_text((300,384),text="Press Space To Play",fill="#fff",font=("Helvectica", "16"))
	
	#start the sound mixer, and play our music
	mixer.init(44100, -16, 2, 3072)
	mixer.music.load("NEDM.mp3")
	mixer.music.set_volume(1)
	mixer.music.play(-1,0)
	
	#set the menu_keys function as a key listener via a lambda function
	root.bind_all('<Key>',lambda event: menu_keys(event,root,canvas))
	
	#keep root from closing
	root.mainloop()

main()